package com.example.itcacp.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.itcacp.entity.Comment;
import com.example.itcacp.entity.Like;
import com.example.itcacp.repository.mybatis.CommentMapper;
import com.example.itcacp.service.CommentService;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CommentServiceImpl extends ServiceImpl<CommentMapper, Comment> implements CommentService {

    @Resource
    private CommentMapper commentMapper;

    /**
     * 查询当前内容下的所有评论、回答等
     * */
    @Override
    public List<Comment> commentList(Long contentId, Like.ContentType contentType) {
        return commentMapper.findTopLevelComments ( contentId, contentType);
    }

    /**
     * 添加评论、回复、回答
     * */
    @Override
    public void addComment(Comment comment) {
        commentMapper.insert ( comment );
    }

}
